//
//  CollectionViewCell.m
//  动起来
//
//  Created by 李成鹏 on 16/8/16.
//  Copyright © 2016年 MorpLCP. All rights reserved.
//

#import "CollectionViewCell.h"

@implementation CollectionViewCell

- (void)awakeFromNib {
    self.btnCityName.layer.masksToBounds = YES;
    self.btnCityName.layer.cornerRadius = 3;
    self.btnCityName.layer.borderWidth = 0.5;
    self.btnCityName.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.btnCityName.backgroundColor = [UIColor whiteColor];
}
- (IBAction)action2Select:(id)sender {
    [[NSUserDefaults standardUserDefaults] setObject:self.btnCityName.titleLabel.text forKey:@"currentCity"];
    NSMutableArray *array = [NSMutableArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"RecentlyCity"]];
    if (![array containsObject:self.btnCityName.titleLabel.text]) {
        if (array.count == 10) {
            [array removeLastObject];
        }
    } else {
        [array removeObject:self.btnCityName.titleLabel.text];
    }
    [array insertObject:self.btnCityName.titleLabel.text atIndex:0];
    [[NSUserDefaults standardUserDefaults] setObject:array forKey:@"RecentlyCity"];
    self.btnClick();
}

@end
